package net.ryian.sms.service.impl;

import com.alibaba.fastjson.JSONObject;
import org.apache.log4j.Logger;

/**
 * Created by allenwc on 16/9/20.
 */
@Deprecated
public class TaobaoSmsService extends BaseSmsService {
    private static final Logger logger = Logger.getLogger(TaobaoSmsService.class);

    private String url;
    private String appkey;
    private String secret;
    private Long signatureId;
    private String signature;

    public TaobaoSmsService() {
        super();
        url = prop.getProperty("taobaosms.url");
        appkey = prop.getProperty("taobaosms.appkey");
        secret = prop.getProperty("taobaosms.secret");
        signatureId = Long.parseLong(prop.getProperty("taobaosms.signatureId"));
        signature = prop.getProperty("taobaosms.signature");
    }

    @Override
    public void send(String mobile, String msg) throws Exception {
        throw new Exception("unsupported method!");
    }

    @Override
    public void send(String mobile, String template, String... values) throws Exception {
//        TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
//        OpenSmsSendmsgRequest req=new OpenSmsSendmsgRequest();
//        OpenSmsSendmsgRequest.SendMessageRequest sendMessageRequest = new OpenSmsSendmsgRequest.SendMessageRequest();
//        sendMessageRequest.setTemplateId(Long.parseLong(prop.getProperty(template)));//模板ID
//        sendMessageRequest.setSignatureId(signatureId);//签名id
//        if(values != null && values.length>0) {
//            JSONObject obj = new JSONObject();
//            for(int i=0;i<values.length;i++) {
//                obj.put(String.valueOf(i+1),values[i]);
//            }
//            sendMessageRequest.setContextString(obj.toJSONString());
//        }
//        sendMessageRequest.setMobile(mobile);
//        req.setSendMessageRequest(sendMessageRequest);
//        OpenSmsSendmsgResponse response = client.execute(req);
//        logger.info(response.getBody());
//        if (response.isSuccess()) {
//            response.getResult().getMessage();
//            response.getResult().getSuccessful();
//        } else {
//            response.getResult().getMessage();
//            response.getResult().getSuccessful();
//        }
    }

	@Override
	public void send(String mobile, String templatecode, String signature, String... values) throws Exception {
		// TODO Auto-generated method stub
		
	}

}
